package com.jbp.controller;

import com.jbp.exception.RRException;
import com.jbp.model.WalletMention;
import com.jbp.model.WalletPay;
import com.jbp.service.WalletMentionService;
import com.jbp.utils.PageUtils;
import com.jbp.utils.R;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * 提现(WalletMention)表控制层
 * @author cc
 * @since 2020-07-02 11:45:11
 */
@Api(tags ="APP接口--提现" )
@ApiIgnore
@RestController
@RequestMapping("rest/mention")
public class WalletMentionController {
    @Autowired
    private WalletMentionService walletMentionService;

    /** 列表 */
    @ApiOperation(value="列表")
    @ApiResponses({
            @ApiResponse(code = 200,message = "成功",response = WalletMention.class),
            @ApiResponse(code = 201,message = "返回失败信息")
    })
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params, @RequestAttribute("userId")Integer userId){
        params.put("userId", userId);
        PageUtils page = walletMentionService.queryPage(params);
        return R.ok().put("data", page);
    }

    /** 提现申请 */
    @ApiOperation(value="提现申请", notes = "这里本来是设计的传爱心，后来改成钱了，参数没变")
    @PostMapping("/mention")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "aixin",value = "爱心数量",paramType = "body")
    })
    public R mention(@RequestBody WalletMention walletMention, @RequestAttribute("userId")Integer userId){
        throw new RRException("敬请期待");
        /*if (walletMention.getAixin().intValue()<100) {
            throw new RRException("提现金额错误");
        }
        walletMention.setAixin(BigDecimal.valueOf(walletMention.getAixin().intValue()));
        walletMention.setUserId(userId);
        walletMentionService.mention(walletMention);*/
//        return R.ok();
    }
}